#include<iostream>
#include<cstdlib>
#include<assert.h>
using namespace std;
int n;
typedef struct Node
{
	int data;
	struct Node* next;
}Node,*Link;
void Init_Link(Link head)
{
	head->next = NULL;
}
void Print_Link(Link head)
{
	Link p = head->next;
	while (p)
	{
		cout << p->data << " ";
		p = p->next;
	}
	cout << endl;
}
void Create_Link(Link head, int arr[])
{
	Link rear = head;
	for (int i = 0; i < n; i++)
	{
		Link node = (Link)malloc(sizeof(Node));
		assert(node);
		node->data = arr[i];
		rear->next = node;
		rear = node;
	}
	rear->next = NULL;
}
void Reserve_Link(Link head, int left, int right)
{
	if (!head->next) {
		return;
	}
	Link Phead = head->next;
	Link a = Phead;
	for (int i = 0; i < left - 1; i++)
	{
		a = a->next;
	}
	Link b, c;
	b = a->next;
	c = b->next;
	for (int i = 0; i < right - left; i++)
	{
		Link d = c->next;
		c->next = b;
		b = c;
		c = d;
	}
	a->next->next = c;
	a->next = b;
}
int main()
{
	Link head = (Link)malloc(sizeof(Node));
	assert(head);
	Init_Link(head);
	cin >> n;
	int arr[15];
	for (int i = 0; i < n; i++) {
			cin >> arr[i];
	}
	Create_Link(head, arr);
	Print_Link(head);
	int left;
	int right;
	cin >> left >> right;
	Reserve_Link(head, left-1, right-1);
	Print_Link(head);
	return 0;
}
